FragmentManager
Static library support version of the framework's android.app.FragmentManager. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework FragmentManager documentation for a class overview.
Your activity must derive from FragmentActivity to use this. From such an activity, you can acquire the FragmentManager by calling getSupportFragmentManager.
Types
Link copied to clipboard
interface BackStackEntry
Representation of an entry on the fragment back stack, as created with FragmentTransaction.addToBackStack().
Link copied to clipboard
Callback interface for listening to fragment state changes that happen within a given FragmentManager.
Link copied to clipboard
interface OnBackStackChangedListener
Interface to watch for changes to the back stack.
Properties
Link copied to clipboard
Flag for popBackStack and popBackStack: If set, and the name or ID of a back stack entry has been supplied, then all matching entries will be consumed until one that doesn't match is found or the bottom of the stack is reached.
Link copied to clipboard
Functions
Link copied to clipboard
Add a FragmentOnAttachListener that should receive a call to onAttachFragment when a new Fragment is attached to this FragmentManager.
Link copied to clipboard
open fun addOnBackStackChangedListener(@NonNull listener: FragmentManager.OnBackStackChangedListener)
Add a new listener for changes to the fragment back stack.
Link copied to clipboard
Start a series of edit operations on the Fragments associated with this FragmentManager.
Link copied to clipboard
Clears the back stack previously saved via saveBackStack.
Link copied to clipboard
Clears the stored result for the given requestKey.
Link copied to clipboard
Clears the stored FragmentResultListener for the given requestKey.
Link copied to clipboard
Control whether the framework's internal fragment manager debugging logs are turned on.
Link copied to clipboard
Control whether FragmentManager uses the new state predictive back feature that allows seeing the previous Fragment when using gesture back.
Link copied to clipboard
After a FragmentTransaction is committed with FragmentTransaction.commit(), it is scheduled to be executed asynchronously on the process's main thread.
Link copied to clipboard
Link copied to clipboard
Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction.
Link copied to clipboard
Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.
Link copied to clipboard
Recurse up the view hierarchy, looking for a FragmentManager
Link copied to clipboard
Return the BackStackEntry at index index in the back stack; entries start index 0 being the bottom of the stack.
Link copied to clipboard
Return the number of entries currently in the back stack.
Link copied to clipboard
Retrieve the current Fragment instance for a reference previously placed with putFragment.
Link copied to clipboard
Gets the current FragmentFactory used to instantiate new Fragment instances.
Link copied to clipboard
Get a list of all fragments that are currently added to the FragmentManager.
Link copied to clipboard
Link copied to clipboard
Return the currently active primary navigation fragment for this FragmentManager.
Link copied to clipboard
Returns the current policy for this FragmentManager.
Link copied to clipboard
Returns true if the final Activity.onDestroy() call has been made on the FragmentManager's Activity, so this instance is now dead.
Link copied to clipboard
Link copied to clipboard
Returns
true
if the FragmentManager's state has already been saved by its host.Link copied to clipboard
Callback for when the FragmentContainerView becomes available in the view hierarchy and the fragment manager can add the fragment view to its hierarchy.
Link copied to clipboard
Link copied to clipboard
Pop the top state off the back stack.
Pop all back stack states up to the one with the given identifier.
Pop the last fragment transition from the manager's fragment back stack.
Link copied to clipboard
Like popBackStack, but performs the operation immediately inside of the call.
Link copied to clipboard
Link copied to clipboard
open fun registerFragmentLifecycleCallbacks(@NonNull cb: FragmentManager.FragmentLifecycleCallbacks, recursive: Boolean)
Registers a FragmentLifecycleCallbacks to listen to fragment lifecycle events happening in this FragmentManager.
Link copied to clipboard
Remove a FragmentOnAttachListener that was previously added via addFragmentOnAttachListener.
Link copied to clipboard
open fun removeOnBackStackChangedListener(@NonNull listener: FragmentManager.OnBackStackChangedListener)
Remove a listener that was previously added with addOnBackStackChangedListener.
Link copied to clipboard
Restores the back stack previously saved via saveBackStack.
Link copied to clipboard
Save the back stack.
Link copied to clipboard
Save the current instance state of the given Fragment.
Link copied to clipboard
Set a FragmentFactory for this FragmentManager that will be used to create new Fragment instances from this point onward.
Link copied to clipboard
Sets the given result for the requestKey.
Link copied to clipboard
fun setFragmentResultListener(@NonNull requestKey: String, @NonNull lifecycleOwner: LifecycleOwner, @NonNull listener: FragmentResultListener)
Sets the FragmentResultListener for a given requestKey.
Link copied to clipboard
Sets the policy for what actions should be detected, as well as the penalty if such actions occur.
Link copied to clipboard
open fun unregisterFragmentLifecycleCallbacks(@NonNull cb: FragmentManager.FragmentLifecycleCallbacks)
Unregisters a previously registered FragmentLifecycleCallbacks.